package com.wealth.system.repository.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.wealth.system.entity.Role;
import com.wealth.system.repository.RoleCustomerDao;

/**
 * 
 * @author chan
 */

public class RoleDaoImpl implements RoleCustomerDao {

	@PersistenceContext
 	private EntityManager em;
	
	/** HQL多对多查询 */
	@Override
	@SuppressWarnings(value="all")
	public List<Role> findRoleListByUserId(Long userid) throws Exception {
		String hql = "select r from Role r join r.userList u where r.status=1 and u.id =  "+userid;
		Query query = em.createQuery(hql);
		List<Role> roleList = query.getResultList();
		return roleList;
	}
}


